<template>
	<view class="wrap">
		<u-navbar :is-back="false" title="" :border-bottom="false"></u-navbar>
		<view class="header">
			<view class="userinfo">
				<view class="image" @click="navTo('info')">
					<u-avatar size="120"  src="/static/aidex/images/user01.png"></u-avatar>
				</view>
				<view class="info" style="display: flex;justify-content: space-between;">
					<view>
						<view class="username">管理员</view>
						<view class="usercode">路亚集团有限公司</view>
					</view>
					<view class="sign-in-images"><image src="/static/aidex/images/sign-in.png"></image></view>
				</view>
			</view>
			<u-row class="userinfo-topbox" gutter="16" justify="center">
				<u-col span="6" text-align="center">
					<view class="number">24</view>
					<view>发起工单数</view>
				</u-col>
				<u-col span="6" text-align="center">
					<view class="number">827</view>
					<view>完成工单数</view>
				</u-col>
			</u-row>
		</view>
		<u-gap height="16" bg-color="#f5f5f5"></u-gap>
		<view class="list">	
			<view>
				<u-cell-group :border-bottom="false" :border="false" class="personal-list">
					<view class="myself" @click="navTo('/pages/sys/user/secure')">
						<view class="left">
							<image src="/static/icon-1.png" mode=""></image>
							<text>账户与安全</text>
						</view>
						<image src="/static/icon-jiantou.png" mode=""></image>
					</view>
					<view class="myself">
						<view class="left">
							<image src="/static/icon-2.png" mode=""></image>
							<text>用户使用协议</text>
						</view>
						<image src="/static/icon-jiantou.png" mode=""></image>
					</view>
					<view class="myself">
						<view class="left">
							<image src="/static/icon-3.png" mode=""></image>
							<text>隐私协议</text>
						</view>
						<image src="/static/icon-jiantou.png" mode=""></image>
					</view>
					<u-gap height="16" bg-color="#f5f5f5"></u-gap>
					<view class="loginOut" @click="logout">退出登录</view>
				</u-cell-group>
			</view>
		</view>
		<plus-actionsheet></plus-actionsheet>
	</view>
</template>
<script>
import plusActionsheet from '../../../pages/common/dialog.vue'
export default {
	components: {
		plusActionsheet
	},
	data() {
		return {
			iconSize: 38
		};
	},
	computed: {
		avatarUrl() {
			// let url = this.vuex_user.avatarUrl || '/ctxPath/static/images/user1.jpg';
			// url = url.replace('/ctxPath/', this.vuex_config.baseUrl + '/');
			let url = this.vuex_config.baseUrl+ this.vuex_user.avatar ||  '/static/aidex/tabbar/my_2.png';
			url = this.replaceAll(url,'\\','/');
			return url + '?t=' + new Date().getTime();
		}
	},
	methods: {
		// 点击底部导航栏清除页面状态
		onTabItemTap() {
			if (this.$store.state.vuex_stata) {
				this.$store.state.vuex_stata = false
			}
		},
		navTo(url) {
			uni.navigateTo({
				url: url
			});
		},
		logout() {
			this.$u.api.logout().then(res => {
				this.$u.toast(res.msg);
				if (res.code == '200' || res.code == '401') {
					let self = this;
					self.$u.vuex('vuex_token', '')
					self.$u.vuex('vuex_user', {})
					setTimeout(() => {
						uni.reLaunch({
							url: '/pages/sys/login/index'
						});
					}, 500);
				}
			});
		},
		upgrade(){
			// #ifdef APP-PLUS
			this.$u.api.upgradeCheck().then(res => {
				if (res.result == 'true'){
					uni.showModal({
						title: '提示',
						content: res.message + '是否下载更新？',
						showCancel: true,
						success: function (res2) {
							if (res2.confirm) {
								plus.runtime.openURL(res.data.apkUrl);
							}
						}
					});
				}else{
					this.$u.toast(res.message);
				}
			});
			// #endif
			// #ifndef APP-PLUS
			this.$u.toast('小程序端或H5端无需检查更新')
			// #endif
		}
	}
};
</script>
<style lang="scss">
@import 'index.scss';
page {
	background-color: #f5f5f5;
}
.wrap .u-cell-box .u-cell_title{
	color:#202328;
}
.sign-in-images{
	width: 125rpx;
	height:50rpx;
	position: absolute;
	right: 0;
	top:5px;
	uni-image{
		width: 125rpx;
		height:50rpx;
	}
}
</style>
